#ifndef CYDEVICE_H
#define CYDEVICE_H

#include <Windows.h>
#include <QtCore>
#include "CyAPI.h"

class CyDevice: public QObject
{
	Q_OBJECT

public:
	CyDevice(int height, int width);

	bool openDevice(HANDLE hnd);
	void closeDevice();
	void setDataSavingSpace(UCHAR *data);
	void setDataSavingSpace(UCHAR *dataBuffer1, UCHAR *dataBuffer2);
	void enableReceving();
	void disableReceving();
	
	bool sendControlCode(int code);

	void setWidth(int width);
	void setHeight(int height);
	void setSize();

	void setPauseFlag(bool flag);

	void changeWidthTo8bitsPerPixel();
	void changeWidthTo16bitsPerPixel();
signals:
	void completeFrameTransmission(unsigned char *data);
	void completeFrameTransmission(unsigned char *data, bool is8bitsPerPixel);
	void completeFrameTransmission();

public slots:
	void receiveData();


private:
	int m_height;
	int m_width;
	LONG m_size;
	UCHAR *m_dataBuffer1;
	UCHAR *m_dataBuffer2;
	bool m_recevingFlag;
	bool m_pauseFlag;
	bool m_is8bitsPerPixel;
	bool m_widthPerPixelChanged;

	QMutex mutex;
public:
	CCyUSBDevice *m_device;
	CCyUSBEndPoint *m_dataInEndPoint;
	CCyControlEndPoint *m_controlEndPoint;

};


#endif